﻿/**
* @description	Class for drawing a rounded rect with a gradient face and a bevel filter applied.
*/	
package com.foed.graphic.skins {

	import flash.display.GradientType;
	import flash.filters.BevelFilter;
	import flash.geom.Matrix;

	public class BeveledGradientRoundedRect extends Skin {

		/**
		* @description	Draws the face of the component.
		*/	
		protected function drawFace():void {
			if (_formatChanged || _sizeChanged || _stateChanged) {
				var pColors:Array;
				switch (_state) {
					case SkinStates.OVER:
						pColors = _styleFormat.getProperty("rolloverFace") as Array;
						filters = [new BevelFilter(4)];
						break;
					case SkinStates.DOWN:
						pColors = _styleFormat.getProperty("selectedFace") as Array;
						filters = [new BevelFilter(4, 235)];
						break;
					default:
						pColors = _styleFormat.getProperty("face") as Array;
						filters = [new BevelFilter(4)];
						break;
				}
				var pAlphas:Array = _styleFormat.getProperty("faceAlpha") as Array;
				var pRatios:Array = _styleFormat.getProperty("faceRatios") as Array;
				var pRotation:Number = _styleFormat.getProperty("faceRotation") as Number;
				var pMatrix:Matrix = new Matrix();
				pMatrix.createGradientBox(_width, _height, pRotation);
				graphics.clear();
				graphics.beginGradientFill(GradientType.LINEAR, pColors, pAlphas, pRatios, pMatrix);
				graphics.drawRoundRect(0, 0, _width, _height, 15);
				graphics.endFill()
			}
		}
	
		/**
		* @description	Draws graphics in the skin, then resets flags.
		*/	
		override protected function redraw():void {
			drawFace();
			super.redraw();
		}

	}

}